<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/view/commom/header-company.jspf"%>
<center>
	<h1>企业主页</h1>
</center>
<hr>
<table class="table">
	<caption>
		<strong>一、职位管理：</strong><a
			href="<%=request.getContextPath()%>/static/company/position-add.jsp">发布职位</a>
	</caption>
	<thead>
		<tr>
			<th>编号</th>
			<th>职位名称</th>
			<th>薪资范围</th>
			<th>发布时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach items="${positionList }" var="position" varStatus="v">
			<tr>
				<th scope="row">${v.count }</th>
				<td><a
					href="<%=request.getContextPath()%>/PositionServlet?command=preupdate&id=${position.id}">${position.name }</a></td>
				<td>${position.salary1 }-${position.salary2 }</td>
				<td><fmt:formatDate value="${position.releaseTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				<td><a
					href="<%=request.getContextPath()%>/PositionServlet?command=delete&id=${position.id}"
					onclick="return confirm('是否删除？');">删除</a></td>
			</tr>
		</c:forEach>
	</tbody>
</table>
<table class="table">
	<caption>
		<strong>二、审核管理：</strong>
	</caption>
	<thead>
		<tr>
			<td colspan="7">
				<form id="conditionForm" action="<%=request.getContextPath() %>/ApplicationServlet?command=listCompanyVerifyByPage" method="post">
					职位名称：<input type="text" name="positionName" value="${applicationCondition.position$name }">
					审核状态：<select name="status">
								<option value="">-全部-</option>
								<option value="1" <c:if test="${applicationCondition.status == 1}">selected=selected</c:if>>待审核</option>
								<option value="2" <c:if test="${applicationCondition.status == 2}">selected=selected</c:if>>已通过</option>
								<option value="3" <c:if test="${applicationCondition.status == 3}">selected=selected</c:if>>已拒绝</option>
							</select>
					<button>查询</button>
				</form>
			</td>
		</tr>
		<tr>
			<th>编号</th>
			<th>职位名称</th>
			<th>求职者</th>
			<th>简历信息</th>
			<th>申请时间</th>
			<th>审核状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach items="${pageModel.list }" var="application" varStatus="v">
			<tr>
				<th scope="row">${v.count }</th>
				<td>${application.position$name }</td>
				<td><a href="javascript:void(0)">${application.talent$name }</a></td>
				<td><a href="javascript:void(0)">${application.resume$intention }</a></td>
				<td><fmt:formatDate value="${application.appTime }"
						pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td>
					<c:if test="${application.status == 1 }">
						${application.statusStr }
					</c:if>
					<c:if test="${application.status != 1 }">
						${application.statusStr }
						(<fmt:formatDate value="${application.handleTime }" pattern="yyyy-MM-dd HH:mm:ss" />)
					</c:if>
					
					<%--  jstl-> if 
			          <c:if test="${application.status == 1 }">
			          		待审核
			          </c:if>
			          <c:if test="${application.status == 2 }">
			          		审核通过
			          </c:if>
			          <c:if test="${application.status == 3 }">
			          		已拒绝
			          </c:if>
			           --%> 
			           
			      <%--  jstl-> if...else
			          <c:choose>
						<c:when test="${application.status == 1 }">
			           	 	  待审核
			           	  </c:when>
						<c:otherwise>
							<c:when test="${application.status == 2 }">
				           	 	 审核通过
				           	  </c:when>
							<c:otherwise>
				           	  	 已拒绝
				           	  </c:otherwise>
						</c:otherwise>
					</c:choose>
				  --%>
				</td>
				<td><a
					href="javascript:verify(${application.id }, ${pageModel.pageNo });">审核</a></td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="7" align="right">
				<a href="javascript:submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=${pageModel.first}')">首页</a>&nbsp;
				<a href="javascript:submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=${pageModel.pre}')">上一页</a>&nbsp;
				第<select onchange="goPage(this)">
				 	<script>
				 		var pageNo = '${pageModel.pageNo }';
				 		var totalPage = '${pageModel.totalPage }';
				 		for (var i = 1; i <= totalPage; i++) {
				 			if (pageNo == i) {
				 				document.write('<option value="' + i + '" selected="selected">' + i + '</option>');
				 			} else {
				 				document.write('<option value="' + i + '">' + i + '</option>');
				 			}
				 		}
				 	</script>
				 </select>页
				,共${pageModel.totalPage }页&nbsp;
				<a href="javascript:submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=${pageModel.next}')">下一页</a>&nbsp;
				<a href="javascript:submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=${pageModel.last}')">尾页</a>&nbsp;
				共${pageModel.allRecords }条记录
			</td>
		</tr>
	</tbody>
</table>
<%@ include file="/view/commom/footer.jspf"%>
<script>
	/**
	 * 信息提示框
	 */
	toastr.options = {
	  "closeButton": true,
	  "debug": false,
	  "positionClass": "toast-top-right",
	  "onclick": null,
	  "showDuration": "300",
	  "hideDuration": "1000",
	  "timeOut": "3000",
	  "extendedTimeOut": "1000",
	  "showEasing": "swing",
	  "hideEasing": "linear",
	  "showMethod": "fadeIn",
	  "hideMethod": "fadeOut"
	}
	if ('${success }') {
		toastr.success('${success }');
	}
	if ('${error }') {
		toastr.error('${error }');
	}
	
	/**
	 * 审核
	 */
	 function verify(applicationId, pageNo) {
	    //询问框
	    layer.confirm('通过还是拒绝？', {
	    	closeBtn: 0,
	        icon : 3,
	        btn: ['通过','拒绝'] //按钮
	    }, function(){
	        layer.msg('您选择了通过！', {icon: 1, time: 1000});
	        location = '<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=2&applicationId=' + applicationId + '&pageNo=' + pageNo;
	    }, function(){
	        layer.msg('您选择了拒绝！', {icon: 2, time: 1000});
	        location = '<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=3&applicationId=' + applicationId + '&pageNo=' + pageNo;
	    });
	}
		
	/**
	 * 跳转到指定的页数
	 */
	function goPage(obj) {
		submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=' + obj.value);
	}
	
	/**
	 * 分页时，使用JS使用表单
	 */
	function submitForm(url) {
		var conditionForm = document.getElementById('conditionForm');
		conditionForm.action = url;
		conditionForm.submit();
	}
</script>